<?php

require_once 'St/Controller/Action.php';

class St_Controller_Action_Admin extends St_Controller_Action {

    protected $acl = null;

    public function init() {
        parent::init();
        if (!$this->auth->hasIdentity() && (St_Registry::getControllerName() != "access")) {
            $this->_redirect("access");
        }
        Zend_Loader::loadClass("St_Acl");
        $this->acl = new St_Acl($this->_getCurrentUser());

        $this->view->headLink()
                ->appendStylesheet($this->externalUrl . 'css/main.css');

        $this->view->headScript()
                ->appendFile($this->externalUrl . 'js/admin.js');

        $translator = St_Registry::get("translator");
        $this->view->navigation()->setUseTranslator($translator);

        $this->view->container = $this->_loadMenu();
    }

    public function _loadMenu($menuName = "default") {
        $user = $this->_getCurrentUser();
        return parent::_loadMenu($user['GroupMenu']);
    }

    protected function isSuperAdmin() {
        $user = $this->_getCurrentUser();
        $groupListSetting = $this->_getPermissionData("group");
        if ($user['groupID'] == $groupListSetting["superadmin_group_id"]) {
            return true;
        }
        return false;
    }

    protected function _getSuperAdminGroupID() {
        $user = $this->_getCurrentUser();
        $groupListSetting = $this->_getPermissionData("group");
        return $groupListSetting["superadmin_group_id"];
    }

}